home *** CD-ROM | disk | FTP | other *** search
/ AMP Graphics Collection / AMP Graphics Collection.iso / programs / 16 / drawing / fgx16e57 / graph3d.sx_ / graph3d.sx
Text File  |  1996-06-30  |  3KB  |  87 lines

  1. clear window
  2.  
  3. display_graph:
  4.     graph_width = 8
  5.     graph_height = 4
  6.     call set_lights
  7.     call set_camera_position
  8.     call make_graph_base
  9.     render mode RENDER_QUICK
  10.     delay 100
  11.     call draw_graph_bars
  12.     return
  13.  
  14. set_camera_position:
  15.     render window 0,0 size GRAPHICS_WINDOW_XMAX,GRAPHICS_WINDOW_YMAX
  16.     camera projection 0.4,0.4,1
  17.     position 16,8,18
  18.     direction 0,0,0
  19.     set camera
  20.  
  21. set_lights:
  22.     position 15,100,35
  23.     my_light = new light
  24.  
  25. make_graph_base:
  26.     base_material = new material color 255,240,128
  27.     call allocate_colors
  28.     base_polygon_1 = new polygon graph_width,0,0; 0,0,0; 0,graph_height,0; graph_width,graph_height,0 material base_material
  29.     base_polygon_2 = new polygon 0,0,0; 0,graph_height,0; 0,graph_height,graph_width; 0,0,graph_width material base_material
  30.     base_polygon_3 = new polygon 0,0,0; 0,0,graph_width; graph_width,0,graph_width; graph_width,0,0 material base_material
  31.     base_polygon_4 = new polygon graph_width,-graph_height/4,graph_width; 0,-graph_height/4,graph_width; 0,0,graph_width; graph_width,0,graph_width material base_material
  32.     base_polygon_5 = new polygon graph_width,-graph_height/4,0; graph_width,-graph_height/4,graph_width; graph_width,0,graph_width; graph_width,0,0 material base_material
  33.  
  34.     load "usflag.gif" bitmap usflag
  35.     load "ukflag.gif" bitmap ukflag
  36.     load "texture1.gif" bitmap texture1
  37.     load "texture2.gif" bitmap texture2
  38.     if GRAPHICS_WINDOW_BITS == 8
  39.         compose bitmap usflag
  40.         compose bitmap ukflag
  41.         compose bitmap texture1
  42.         compose bitmap texture2
  43.         remap bitmap usflag
  44.         remap bitmap ukflag
  45.         remap bitmap texture1
  46.         remap bitmap texture2
  47.     texture base_polygon_1 bitmap usflag
  48.     texture base_polygon_2 bitmap ukflag
  49.     texture base_polygon_4 bitmap texture1
  50.     texture base_polygon_5 bitmap texture2
  51.  
  52. allocate_colors:
  53.     my_pal = new byte[256][3]
  54.     for n = 1 to 32
  55.         r = n * 8 - 1
  56.         g = n * 7 - 1
  57.         b = n * 4 - 1
  58.         my_pal[n-1][0] = r,b,g
  59.     compose palette my_pal
  60.  
  61. draw_graph_bars:
  62.     for x = 1 to graph_width
  63.         for z = 1 to graph_width
  64.             bar = call draw_bar
  65.             render mesh bar mode RENDER_QUICK
  66.             free bar
  67.  
  68. draw_bar:
  69.     k = call graph_function: x-graph_width/2, z-graph_width/2, graph_width
  70.     y = k * graph_height
  71.     poly_list = new object list
  72.     poly_1 = new polygon x,y,z; x,y,z-1; x-1,y,z-1; x-1,y,z material base_material
  73.     poly_list push @poly_1
  74.     if (y > 0.1)
  75.         poly_2 = new polygon x,y,z; x,y,z-1; x,0,z-1; x,0,z material base_material
  76.         poly_3 = new polygon x,y,z; x-1,y,z; x-1,0,z; x,0,z material base_material
  77.         poly_list push @poly_2
  78.         poly_list push @poly_3
  79.     return @poly_list
  80.  
  81. local graph_function: x, z, k
  82.     y = cos(x/k*PI) * cos(z/k*PI) * cos(x/k*PI) * cos(z/k*PI) + rnd 0.1
  83.     return y
  84.  
  85.     
  86.  
  87.